package com.sufen.common.reponse;

/**
 * @description:
 * @function: 封装返回的结果
 * @author: Liu Menglei
 * @Date: 2021/11/1 0001 21:19
 */
public class Result<T> {
    private int code;
    private String msg;
    private T data;

    public static <T>   Result<T> success(T data){
        return new   Result<T>(data);
    }

    public static <T>   Result<T> error(  CodeMsg cm){
        return new   Result<T>(cm);
    }

    public Result(){}

    private Result(T data){
        this.code = 0;
        this.msg = "success";
        this.data = data;
    }

    private Result(  CodeMsg cm){
        if(cm==null){
            return;
        }
        this.code = cm.getCode();
        this.msg = cm.getMsg();
    }
}